<template>
  <div>
    <h3 class="title">
      最新推荐
      <span>为你推荐最新好货</span>
    </h3>
    <div class="items">
      <div
        class="item"
        v-for="(item, index) in items"
        :key="item.id"
        @click="clickItem(item.id, index)"
      >
        <img v-lazy="item.pic" class="img"/>
        <div class="item-info">
         <h5 class="name">{{item.name}}</h5>
          <p class="desc">{{item.characteristic?item.characteristic:'暂无描述'}}</p>
          <div class="acion">
            <p class="price">
              ￥{{item.minPrice}}
            </p>
            <van-icon size="25" @click.stop="clickCart(item.id, index)" class-prefix="icon" name="gouwuche"/>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    items: {
      type: Array,
      required: true
    }
  },
  methods: {
    clickCart (id, index) {
      this.$emit('clickCart', { id, index })
    },
    clickItem (id, index) {
      this.$emit('clickItem', { id, index })
    }
  }
}
</script>

<style lang="scss" scoped>
.title {
  width: 100%;
  height: 35px;
  line-height: 35px;
  font-size: 16px;
  color: skyblue;
  font-weight: 400;
  background-color: #fff;
}
.title span {
  font-size: 12px;
  line-height: 40px;
  color: #999;
}
.items {
  .item {
    height: 230px;
    margin: 8px 0;
    display: flex;
    background-color: #fff;
    border-radius: 8px;
    overflow: hidden;
    align-items: center;
    .img {
      width: 180px;
      height: 180px;
    }
    .item-info {
      flex: 1;
      height: 100%;
      padding-top: 20px;
      padding-left: 5px;
      .name {
        font-size: 14px;
        color: #333;
        margin-top: 40px;
        margin-left: 20px;
        line-height: 20px;
      }
      .desc {
        width: 100%;
        font-size: 12px;
        color: #666;
        margin-top: 20px;
        margin-left: 20px;
        line-height: 20px;
      }
      .acion {
        display: flex;
        padding-right: 40px;
        height: 50px;
        align-items: center;
        justify-content: space-between;
        font-size: 16px;
        margin-left: 20px;
        color: #ff734c;
      }
    }
  }
}
</style>
